<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="<s:url value="/css/style.css"/>" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript" src="<s:url value="/js/common.js"/>"></script>
		<script type="text/javascript" src="<s:url value="/js/jquery.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.bgiframe.min.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.ajaxQueue.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/thickbox-compressed.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.autocomplete.js"/>"></script>
		<link rel="stylesheet" type="text/css"
			href="<s:url value="/js/autocomplete/jquery.autocomplete.css"/>" />
		<link rel="stylesheet" type="text/css"
			href="<s:url value="/js/autocomplete/thickbox.css"/>" />
		<script type="text/javascript" src="<s:url value="/js/jquery-ui.js"/>"></script>
		<link href="<s:url value="/css/jquery.css"/>" rel="stylesheet"
			type="text/css" />
		<script type='text/javascript'
			src="<s:url value="/js/ptTimeSelect/jquery.ptTimeSelect.js"/>"></script>
		<link rel="stylesheet" type="text/css"
			href="<s:url value="/js/ptTimeSelect/jquery.ptTimeSelect.css"/>" />
		<script type="text/javascript"
			src="<s:url value="/js/jquery.form.js"/>"></script>
		<script type="text/javascript"
			src="<s:url value="/js/jquery.validate.js"/>"></script>
		<script type="text/javascript">
	function doSubmit() {
		// here is validate form .
		$('#editForm').submit();
	}
	function goBack() {
		window.close();
		//location.href = '<s:url value="/customer/TM/list"/>';
	}
	function leadsStatusControl(){
		var tm = ['New','SetAppt','Invalid','WrongNumber','CallBack','Dead', 'InvalidPhoneNumber','Duplicate', 'NotInterest'];
		var l = document.getElementById('leadsStatus');
		for(var i = l.options.length-1 ;i>0;i--){
		 	switch(l.options[i].value){
			case 'New':
				break;
			case 'SetAppt':
				break;
			case 'Invalid':
				break;
			case 'WrongTelephone':
				break;
			case 'CallBack':
				break;
			case 'Dead':
				break;
			case 'Notinterest':
				break;
			case 'Donotcall':
				break;
			case 'NoAnswer':
				break;
			case 'Noshow':
				break;
			case 'InvalidPhoneNumber':
				break;
			case 'Noshow_CallAgain':
				break;
				case 'Duplicate':
				break;
			case 'Noshow_Reschedule':
				break;	
			default:
				 l.remove(i);
			}
		}
	}
	$( function() {
		leadsStatusControl();
	    $('#editForm').validate();
		$('#initVisitTime').datepicker( {
			dateFormat :'yy-mm-dd'
		});
		$('#depositTime').datepicker( {
			dateFormat :'yy-mm-dd'
		});
		if ($.trim($('#result').text()) != '') {
			popupDiv('pop-div');
		};
		 $("#selMarketingPlan").autocomplete("<s:url value="/marketing/autoCompleteAjax.action"/>", {
		             width: 300,
		             minChars:2, //几个字
		             mastMatch:true,
		             selectFirst: false,
		             max:  20,
		         	   formatItem: function(row, i, max) {
		         	      var d=eval("("+row+")");
			      return  d.name;
		      },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
				     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
		   	       }
		          });
		  	$("#selMarketingPlan").result(function(event, data, formatted) {
		         	      var d=eval("("+data+")");
		          $("#selMarketingPlanId").val(d.id);
		          $("#selAdChannelId").val(d.aid);
		          $("#selAdChannel").val(d.aname);
		          $('#selMarketPolicy').val( d.pid );
		   	});
		  	$("#selAdChannel").autocomplete("<s:url value="/data/AdChannel/autoCompleteAjax.action"/>", {
		             width: 300,
		             minChars:2, //几个字
		             mastMatch:true,
		             selectFirst: false,
		             max:  20,
		         	   formatItem: function(row, i, max) {
		         	      var d=eval("("+row+")");
			      return  d.name;
		         },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
				     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
		   	       }
		          });
		          $("#selAdChannel").result(function(event, data, formatted) {
		         	      var d=eval("("+data+")");
		          $("#selAdChannelId").val(d.id);
		          });
		          $("#selPTE").autocomplete("<s:url value="/data/PTE/autoCompleteAjax.action"/>", {
		             width: 300,
		             minChars:2, //几个字
		             mastMatch:true,
		             selectFirst: false,
		             max:  20,
		         	   formatItem: function(row, i, max) {
		         	      var d=eval("("+row+")");
			      return  d.name;
		         },
		      formatMatch: function(row, i, max) {
		         var d=eval("("+row+")");
				     return d.name;
		      },
		      formatResult: function(row) {
		         var d=eval("("+row+")");
			     return d.name;
		   	       }
		   });
          $("#selPTE").result(function(event, data, formatted) {
         	      var d=eval("("+data+")");
          $("#selPTEId").val(d.id);
          });
          $('#todoEventDate').datepicker( {
			dateFormat :'yy-mm-dd'
	      });
          $('#todoEventTime').ptTimeSelect();
	});
	function goCall(caller,tel) {
		if (!tel){
		   return ;
		}
		$('#currentCalltelephone').val(tel);
		var d=new Date();
		$('#currentCalldealTime').val(d.format("isoDate")+" "+d.format("isoTime"));
	    //var url = "http://192.168.5.166/manager/makecall.php?caller="+ caller+"&callee="+tel;
        //jQuery.post(url);
		var url = "<s:url value="/customer/TM/callFromCallCenter.action"/>";
        var params = {
              caller:caller,
              tel:tel
        };
        jQuery.post(url, params);
    };
</script>
		<title><s:text name="system.title" /></title>
	</head>
	<!-- CYG100225 body onUnload="opener.location.reload();"  -->
	<body>
		<s:include value="/common/up.jsp"></s:include>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td class="box">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td id="tag-over">
								<span id="tag-over">Call</span>
							</td>
							<td class="tab3-line" width="90%">
								&nbsp;

							</td>
						</tr>
					</table>
					<s:form action="TM/saveCall" namespace="/customer" method="post"
						id="editForm" name="editForm">
						<s:hidden name="id"></s:hidden>
						<table width="100%" border="0" cellpadding="3" cellspacing="1"
							class="margin">
							<tr>
								<td align="right" class="tablecolour5">
									Name
									<font color="red">*</font>:
								</td>
								<td class="tablecolour5">
									<s:textfield name="name" cssClass="input2 required" size="15" />
								</td>
								<td align="right" class="tablecolour5">
									Gender:
								</td>
								<td class="tablecolour5">
									<s:textfield name="salutation" cssClass="input2" size="15" />
								</td>
								<td align="right" class="tablecolour5">
									Age:
								</td>
								<td class="tablecolour5">
									<s:textfield name="age" cssClass="input2" size="15" />
								</td>
								<td align="right" class="tablecolour5">
									Education:
								</td>
								<td class="tablecolour5">
									<s:textfield name="education" cssClass="input2" size="15" />
								</td>
							</tr>

							<tr>
								<td align="right" class="tablecolour5">
									Company:
								</td>
								<td class="tablecolour5">
									<s:textfield name="company" cssClass="input2" size="15" />
								</td>
								<td align="right" class="tablecolour5">
									E-mail:
								</td>
								<td class="tablecolour5">
									<s:textfield name="email" cssClass="input2" size="15" />
								</td>
								<td class="tablecolour5">
									MarketingPlan:
								</td>
								<td class="tablecolour5">
									<s:property value="marketingPlan.name"  /> 
									<br/>
									PTE Lead:
									<s:property value="pteLeader.name"  />
									PTE:
									<s:property value="pte.name"  />
								</td>
								<td align="right" class="tablecolour5">
									Create Time:
								</td>
								<td class="tablecolour5">
									<s:date name="createTime" format="yyyy-MM-dd" />
								</td>
							</tr>
							<tr>

								<td align="right" class="tablecolour5">
									Ad Channel:
								</td>
								<td class="tablecolour5">
									<s:textfield id="selAdChannel" name="adChannel.name"
										cssClass="input2" size="15" />
									<s:hidden id="selAdChannelId" name="adChannel.id" />
								</td>
								<td align="right" class="tablecolour5">
									Init Visit Time:
								</td>
								<td class="tablecolour5">
									<s:date name="initVisitTime" format="yyyy-MM-dd"
										var="initVisitTimefmt" />
									<s:textfield name="initVisitTime" cssClass="input2" size="15"
										id="initVisitTime" value="%{initVisitTimefmt}" />
								</td>
								<td align="right" class="tablecolour5" rowspan='2'>
									Comments:
								</td>
								<td class="tablecolour5" colspan="3"  rowspan='2'>
									<s:textarea name="comments" cols="60" rows="5" />
								</td>
							</tr>
							<tr>
								<td align="right" class="tablecolour5">
									Leads Source:
								</td>
								<td class="tablecolour5">
									<s:select name="leadsSource" headerValue="--select--"
										headerKey="" list="@com.ef.constant.ELeadsSource@values()"
										listKey="name()" />
								</td>
								<td align="right" class="tablecolour5">
									Leads Type:
								</td>
								<td class="tablecolour5">
									<s:select name="leadsType" headerValue="--select--"
										headerKey="" list="@com.ef.constant.ELeadsType@values()"
										listKey="name()" />
								</td>
							</tr>
							<tr>
								<td align="right" class="tablecolour5">
									Marketing Policy:
								</td>
								<td class="tablecolour5">
									<s:select id="marketPolicy" headerValue="--select--"
										headerKey="" name="marketingPolicy.id"
										list="marketingPolicyList" />
								</td>
								<td align="right" class="tablecolour5">
									TM/CC
								</td>
								<td class="tablecolour5">
									<s:property value="tm.name" />
									/
									<s:property value="cc.name" />
								</td>
								<td align="right" class="tablecolour5">
									Last Comments:
								</td>
								<td class="tablecolour5" colspan="3">
									<s:property value="lastEventCommons" />		
								</td>
							</tr>
							<tr>
								<td align="right" class="tablecolour5">
									Telephone:
								</td>
								<td class="tablecolour5">
									<s:textfield name="telephone" cssClass="input2" size="15" />
								</td>
								<td align="right" class="tablecolour5">
									Mobile:
								</td>
								<td class="tablecolour5">
									<s:textfield name="mobileTelephone" cssClass="input2" size="15" />
								</td>
								<td align="right" class="tablecolour5">
									Leads Status:
								</td>
								<td class="tablecolour5">
									<s:select name="leadsStatus" headerValue="--select--"
										headerKey="" list="@com.ef.constant.ELeadsStatus@values()"
										listKey="name()" id="leadsStatus" />
								</td>
									<td class="tablecolour5" align="right">
									School:
								</td>
								<td class="tablecolour5">
									<s:select id="school" headerValue="----select---" headerKey=""
										name="school.id" list="schoolList" />
								</td>
							</tr>
	                        <tr>
	                        	<td align="center" colspan="8" height="50" class="tablecolour5">
								    <input name="goback" type="button" class="btn1" value="Close"
										onclick="goBack()" />
								</td>
							</tr>
						</table>
 						<table cellpadding="3" cellspacing="1" width="100%"
							style="margin-top: 5px;" class="margin">
							<tr>
								<td colspan="5" class="title">
									Event History
								</td>
							</tr>
							<tr>
								<td class="tablecolour5">
									Task Type
								</td>
								<td class="tablecolour5">
									Call Number
								</td>
								<td class="tablecolour5">
									Call Time
								</td>
								<td class="tablecolour5">
									Comment
								</td>
								<td class="tablecolour5">
									Call Status
								</td>
							</tr>
							<s:iterator value="calls">
								<tr>
									<td class="tablecolour5">
										<s:property value="eventType" />
									</td>
									<td class="tablecolour5">
										<s:property value="telephone" />
									</td>
									<td class="tablecolour5">
										<s:date name="dealTime" format="yyyy-MM-dd HH:mm" />
									</td>
									<td class="tablecolour5">
										<s:property value="comments" />
									</td>
									<td class="tablecolour5">
										<s:property value="callStatus" />
									</td>
								</tr>
							</s:iterator>
						</table>
					</s:form>
				</td>
			</tr>
		</table>
		<s:include value="/common/down.jsp"></s:include>
		<div id='pop-div' style="width: 300px;" class="pop-box">
			<s:include value="/common/confirmPopup.jsp"></s:include>
		</div>
	</body>
</html>